import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.UserListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

const operationParams = [
  {
    label: '新增',
    value: 1,
  },
  {
    label: '编辑',
    value: 2,
  },
  {
    label: '删除',
    value: 3,
  },
  {
    label: '审批',
    value: 4,
  },
];

export const columns: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入账号、操作人名称搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },
  {
    title: '时间筛选',
    dataIndex: 'time',
    hideInTable: true,
    formItemProps: {
      component: 'RangePicker',
      componentProps: () => {
        return {
          format: 'YYYY/MM/DD HH:mm:ss',
          valueFormat: 'YYYY/MM/DD HH:mm:ss',
          showTime: true,
        };
      },
    },
  },
  {
    title: '登录账号',
    align: 'left',
    dataIndex: 'userLogin',
    hideInSearch: true,
  },
  {
    title: '操作人',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '操作类型',
    align: 'left',
    dataIndex: 'operationType',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams,
      },
    },
    customRender: ({ record }) =>
      operationParams.filter((item) => item.value == record.operationType)[0].label,
  },
  {
    title: '提示信息',
    align: 'left',
    dataIndex: 'action',
    hideInSearch: true,
  },
  {
    title: '操作时间',
    align: 'left',
    dataIndex: 'operationTime',
    hideInSearch: true,
  },
];
